Repository navigation
feat(rest,metadata-protocol,spec): the per-item publish takes a draft-version pin, so Save to this view never publishes a moved draft - #37387
Conversation
…asurement, M1 red on main) Measurement only, for a needs_decision report: M1 shows the publish door's active-row If-Match does not see a draft written between Save to this view's draft write and its publish; M2 shows a client-side pin on updateView's draft write does not either; M0 and M3 record the tokens and the active-save door's answer. Not for landing. Claude-Session: https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re Co-authored-by: Claude <noreply@anthropic.com>
…ew-draft-publish-pin
…-version pin (draftVersion) The publish door refuses a draft that moved since the caller wrote or read it, 409 METADATA_CONFLICT naming the draft's current token, beside the active-row If-Match pin. Ruling 7168616260 (A1). Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm Co-authored-by: Claude <noreply@anthropic.com>
…to the draft version Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm Co-authored-by: Claude <noreply@anthropic.com>
…e draft they read Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm Co-authored-by: Claude <noreply@anthropic.com>
…est.draftVersion Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 3 package(s): 8 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 180 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 0205816c29915f2e23d423a4b3c9eb3a72e1f6ba && git checkout 0205816c29915f2e23d423a4b3c9eb3a72e1f6ba
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin da7c559990d879de9038ccf54e294e58bbaa647f a586b8c54572f8a0307da2143e41d4292dff22c5 && git checkout -B drift-repro da7c559990d879de9038ccf54e294e58bbaa647f && git merge --no-ff a586b8c54572f8a0307da2143e41d4292dff22c5
node scripts/docs-audit/affected-docs.mjs --json da7c559990d879de9038ccf54e294e58bbaa647f
|
|
repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re Contract reviewServed-tier: Read: card #36350 with all ten comments (ruling record 7168616260, reports 7164597391 and 7179271525), ruling 7058616478 on #35955, the PR body, its 26-file list, and the net diff against Two must-fix findings (M1, M2), three should-fix (S1 to S3), five nits. The door itself holds: I could not make it publish a draft the caller did not pin. ① Derived judgments
② Semver levelM1 (must-fix) — The rest of ② holds. Every published package the diff touches has a changeset: spec, metadata-protocol, rest, data-objectstack, and app-shell with console. ③ Boundary flags
④ Design judgment
S1 (should-fix) — published contract text the diff leaves false.
S2 (should-fix) — the member is added to the private
M2 (must-fix) — ruling item 3 is not met on the draft bar's main path. Item 3: the bar's Publish "passes the draft token it showed, which closes the dev's out-of-scope finding on that caller". Line 151 clears the shown version when Nits:
Implemented-by: VERDICT: FAIL |
…in — protocol kind, bar pin after the host's save, conflict text Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm Co-authored-by: Claude <noreply@anthropic.com>
…ict text Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re Contract reviewServed-tier: This is a DELTA record on record 7179921339 (FAIL at 8eee708: M1, M2, S1 to S3, N1 to N5). Read: the two commits between that head and this one (18 files), the PR body as rewritten at 02:49Z, the seat's correction 7179935180 and the dev's reports 7181146930 and 7181181714 on #36350, and this head's check-runs. Check-runs on this head, read at 2026-11-26T03:19Z with none pending: 74 runs, 62 success, 11 skipped, 1 failure. The failure is the All ten findings are closed. One new nit (N6), one changeset nit (N7). No must-fix, no should-fix. ① Derived judgments
② Semver levelM1: closed.
③ Boundary flags
④ Design judgment
S1: closed. N2: closed. The
S2: closed.
N1: closed. An off-type N3: closed. The acceptance case asserts exactly one The rest of the file is as reviewed at the last head.
S3: closed. A publish conflict whose body parses as
M2: closed. The panel hands the bar the version its save guard holds after each landed save, and the bar pins its Publish to it with no re-read. Followed through on this head:
So the window of the first record (A saves in view settings, B's rename lands, A presses Publish) now ends in a 409 with B's draft left pending. N4: closed. The PR body no longer claims an immediate retry for the bar; it says the author reopens the view settings.
N5: closed (see ③). No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re 席位核对ACCEPT · 2026-11-26T04:20Z · head
|
|
repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re Landing (2026-11-26T04:20Z): head
State: |
Fixes #36350
Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: none —
skills/**teaches no per-item metadata publish request: 0 hits overskills/for a/meta/…/publishroute,PublishMetaItem,publishMetaItem,draftVersionorparentVersion(the oneIf-Matchhit is the dataPATCHroute's optimistic lock).维护者速读
What changes
Ruling 7168616260 (A1) on #36350, executed as ruled:
PublishMetaItemRequestSchemagains one optional member,draftVersion: the version token of the draft the caller wrote or read and means to publish; its describe says the draft is judged first and that an address refusal (404 NO_DRAFT) precedes both pins.parentVersion(If-Match) keeps its shipped meaning, the active row's token; its describe now points at the draft's own pin.MetadataConflictErrorSchemanames the draft pin: on the publish door a refuseddraftVersionreturns the draft's token, sent back asdraftVersion, never asIf-Match, andnullthere means nothing is pending to publish. The publish route's declaration inplugin-rest-api.zod.tslists the 409 causes, both body read keys and the new 400. Generated reference (content/docs/references/api/protocol.mdx) andauthorable-surface/api.jsonregenerated by the build /check:generated --fix.packages/metadata-protocol/src/protocol-history-and-publish.ts) —promoteDraftForPublishjudgesdraftVersionagainst the draft row it just read, before any authoring rule judges that draft, with the save door's keyed comparison (storedParentForToken). A moved draft, or a pinned draft no longer pending, is refused409 METADATA_CONFLICTwithcurrentVersion= the draft's current token (nullwhen none), nothing promoted, and the same optimistic-conflict audit row as the other publish conflicts. An off-typedraftVersionfrom an in-process caller is refused400 VALIDATION_ERROR, never read as unpinned.PublishMetaItemRequest(protocol-door-requests.ts, the publicpublishMetaItemtype) now declaresdraftVersionandparentVersion. The existingexpectedDraftHashkeeps the promotion locked to that row through the write. The conflict-to-refusal mapping moved into one local helper shared by the pin and the promotion's owncatch(same text and audit as before for the existing two conflicts).packages/rest/src/meta-item-history-routes.ts) —POST /meta/:type/:name/publishreadsdraftVersionfrom its body besidemessageand forwards it when present; a present non-string is refused400 VALIDATION_ERROR, never read as absent.ui/packages/data-objectstack) —MetadataClient.publishtakesdraftVersionand sends it in the body.ObjectStackAdapter.updateView's draft branch reads the draft throughgetDraft(the envelope carriesversion) BEFORE the layered read it merges from, and writes pinned to it (If-Match, orIf-None-Match: *when the read saw no draft).ui/packages/app-shell/src/views/) — "Save to this view" (saveAndPublishRuntimeMetadata) passes the version its own draft write returned; a moved draft's409resolves'pending-draft'and the moved draft is NOT discarded (it now holds the other writer's change); a409withcurrentVersion: null(the draft was published or discarded by someone else) rethrows, since there is no draft to review. The runtime draft bar's Publish (publishRuntimeMetadata) passes the draft token the bar shows: on open, the one its draft read (readRuntimeDraftForPublish, throughgetDraft) returned; after its host's own save, that save's receipt version, which the view settings panel hands it assavedDraftVersionfrom its draft-version guard (useDraftSaveGuard().heldDraftVersion). Never a blind re-read.Absent
draftVersionis unpinned everywhere, as before.Why
Measured on main before any code (report 7164597391, re-run on the merged tree here): "Save to this view"'s draft write, then an
updateView-style draft write, then the publish pinned with the only pin main offered (If-Matchon the active row) answered 200 and published the interleaved draft. Ruling 7058616478 (#35955): an unpublished draft is never published on someone else's behalf.Tests
packages/rest/src/meta-item-publish-version-pin.test.ts(new top-level describe, ruling record 6583487846), real stack at the HTTP door:updateViewdraft write (pinned, and unpinned) interleaved between Save's draft write and its publish: refused409 METADATA_CONFLICT,currentVersion= the moved draft's token (parsed byMetadataConflictErrorSchema), active row unchanged, moved draft still pending;409,currentVersion: null; a draft token sent asIf-Matchstill answers the active row's refusal; non-stringdraftVersion(number, null, object):400 VALIDATION_ERROR, nothing promoted; in process, an off-typedraftVersionis refused400by the protocol; the acceptance refusal writes onepublish/deniedmetadata_conflictaudit row.meta-item-publish-draft-interleave-36350.test.tsis removed: its M1 is now the acceptance pin above; M0 (token identity) is asserted there (readDraft().versionequals the receipt and the refusal'scurrentVersion); M2 and M3 measured options B-extended and C, which the ruling did not take, and their readings stay recorded in report 7164597391.protocol.test.tspinsdraftVersionpreserved through parse, absent stays absent, non-strings refused.updateView.draft.test.ts(new describe:If-Matchfrom the draft read, read before the layers;If-None-Match: *when the read saw none; a409reaches the caller; no version pins nothing),metadata-client.publishPackageBinding.test.ts(body carriesdraftVersionbesidemessage; omitted, no key),runtime-metadata-persistence.test.ts(Save passes its receipt's version; a moved draft resolvespending-draftand is not discarded;currentVersion: nullrethrows; draft bar passes the shown token),RuntimeDraftBar.test.tsx(Publish sends the shown version; refusal keeps the bar; after the host's own save the Publish is pinned to that save's receipt version with no re-read; the save-then-publish window refuses another writer's draft; a host with no receipt version stays unpinned),ViewConfigPanel.pinnedDraftSave-36137.test.tsx(each landed save hands the bar its own receipt version). Four existing draft-bar /updateViewdoubles now answergetDraftand the drafts ledger.Readings (head a0b4863; first round at 8cee422/8eee7080 in report 7179271525)
pnpm --filter @objectstack/rest exec vitest run src/meta-item-publish-version-pin.test.ts—Tests 18 passed (18)(adds the in-process off-type pin and the audit-row assertion).draftVersioncheck mutated, metadata-protocol rebuilt, marker indist/:Tests 3 failed | 14 passed (17); restored blob == HEAD, rebuilt,--absentclean:17 passed.shownDraftVersionRef.current = savedDraftVersion;replaced viascripts/ablation-replace.mjs(blobda8e79d7->e00baf11):RuntimeDraftBar.test.tsxTests 2 failed | 11 passed (13)(the after-save pin and the save-then-publish window); restored, blob == HEAD,git diff HEADempty.pnpm --filter @objectstack/spec test—Test Files 895 passed (895),Tests 28420 passed | 1 todo.pnpm --filter @objectstack/metadata-protocol test—Test Files 370 passed | 9 skipped (379),Tests 23435 passed | 45 skipped.pnpm --filter @objectstack/rest test—Test Files 429 passed (429),Tests 8852 passed | 351 skipped.ui(vitest run): the draft-bar, persistence, view-settings and report files plus all ofpackages/app-shell/src/views/metadata-admin/—Test Files 810 passed (810),Tests 8717 passed | 1 skipped.packages/data-objectstack/(unchanged this round) —127 passedin round 1. The fullpackages/app-shell/suite was not re-run this round;Test UIcarries it.@objectstack/spec,@objectstack/metadata-protocol,@objectstack/resttypecheckand@object-ui/app-shelltype-check, chained with&&:VERDICT command-exit 0.Acceptance notes
parentVersion) is still judged where Studio save goes live: two admins saving the same published object, the later save silently overwrites the earlier one (the published layer has no version a save can pin) #36601 put it, inside the promotion.'pending-draft'(the same answer as over a draft found pending before its write) and leaves the draft for review. That draft holds this save's body with the other writer's change on top; it is not discarded because it is no longer this call's own.updateViewnow reads its draft sequentially (getDraft, then/layers) instead of in parallel, one extra round trip, so a pin can only be older than the body it merges, never newer.savedSignal, which the view settings panel bumps on every landed save), pins its Publish to that save's receipt version (savedDraftVersion). A host that gives no receipt version leaves that Publish unpinned, as before.draftVersionyet (studio-design/studioSaveBar.tsxtwice,metadata-admin/DraftConflictDialog.tsx,metadata-admin/detailSaveAtOnce.ts,recordTabsConfigSave.ts,objectExtensionArrangementSave.ts,layout/designModeMenuSave.tstwice), and@objectstack/client'spublishItemcan state neither pin. The member is opt-in by ruling; ruling item 3 named the four callers this PR pins.Verification
Gates (local subset, derived by dispatch-gates.mjs from the diff, on a0b4863)
node scripts/pm/dispatch-gates.mjs --ran(exit codes recorded):125 derived, 123 run, 2 NOT-MEASURED, 0 UNRUN.node scripts/check-plugin-teardown-shape.mjs --self-test: exit 3, its positive control is pinned to a commit this shallow clone cannot reach. CI runs it.pnpm check:dual-build-cjs-loads: exit 3, packages outside this diff have nodist/in this container (PREREQUISITE NOT MET). CI runs it.pnpm --filter @objectstack/spec run check:skill-examples: exit 3 untilclient-reactwas built, then exit 0.pnpm --filter @objectstack/spec check:generated:check:docsstale after the conflict-text edit, regenerated with--fixand committed;check:api-surfacegreen on the built dist.overlap-check:VERDICT cleanagainst origin/main and the one PR head sharing a file (feat(security)!: View All and Modify All stop opening fields; viewAllFields is the one every-field bit #37371, generated reference page: merges cleanly).Two-minute check:
pnpm --filter @objectstack/rest exec vitest run src/meta-item-publish-version-pin.test.ts— expectTests 18 passed (18), including the[#36350]describe.Read first (by risk):
packages/metadata-protocol/src/protocol-history-and-publish.ts(the pin and the shared conflict helper),ui/packages/app-shell/src/views/RuntimeDraftBar.tsxwithViewConfigPanel.tsx(the pin after the host's save),ui/packages/app-shell/src/views/runtime-metadata-persistence.ts(the no-discard and nothing-pending branches).Human Minimum
packages/specholds no runtime logic.pnpm lintpasses (CI-owned run).main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm
Generated by Claude Code